Advertisement
Guest User

MisterDai

a guest
Oct 8th, 2009
784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!--- Function for undoing anything that CfHtmlHead intends to do --->
  2. <cffunction name="resetCFHtmlHead" output="false" returntype="void">
  3.     <cfscript>
  4.         var local = StructNew();
  5.         local.out = getPageContext().getOut();
  6.         while (getMetaData(local.out).getName() Is 'coldfusion.runtime.NeoBodyContent') {
  7.             local.out = local.out.getEnclosingWriter();
  8.         }
  9.         local.method = local.out.getClass().getDeclaredMethod('initHeaderBuffer', ArrayNew(1));
  10.         local.method.setAccessible(true);
  11.         local.method.invoke(local.out, ArrayNew(1));
  12.     </cfscript>
  13. </cffunction>
  14.  
  15. <!--- Function for retrieving anything that CfHtmlHead intends to do --->
  16. <cffunction name="getCFHtmlHead" output="false" returntype="any">
  17.     <cfscript>
  18.         var local = StructNew();
  19.         local.out = getPageContext().getOut();
  20.         while (getMetaData(local.out).getName() Is 'coldfusion.runtime.NeoBodyContent') {
  21.             local.out = local.out.getEnclosingWriter();
  22.         }
  23.         local.field = local.out.getClass().getDeclaredField("headerBuffer");
  24.         local.buffer = 0;
  25.         local.field.setAccessible(true);
  26.         local.buffer = local.field.get(local.out);
  27.         /* The get might return null */
  28.         if (StructKeyExists(local, 'buffer')) {
  29.             return local.buffer.toString();
  30.         } else {
  31.             return '';
  32.         }
  33.     </cfscript>
  34. </cffunction>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement